﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using HiauPdm.Bll;

namespace HiauPdm.Web
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            Application["SessionUsers"] = 0;
        }

        protected void Session_End(object sender, EventArgs e)
        {
            if (Session["LoginTime"] != null)
            {
                Application["SessionUsers"] = ((int)Application["SessionUsers"]) - 1;
            }
            try
            {
                FormsAuthentication.SignOut();
                Session.Clear();
                Session.Abandon();
            }
            catch { }
        }

        protected void Application_End(object sender, EventArgs e)
        {
            Application.Clear();
            try
            {
                string[] sFiles = Directory.GetFiles(BGlobal.AttachmentPath, "Ls*.tmp");
                for (int i = 0; i < sFiles.Length; i++)
                {
                    try { File.Delete(sFiles[i]); }
                    catch { }
                }
            }
            catch { }
        }
    }
}